From d890188573f5efedeb2769753a64ac923f6269ef Mon Sep 17 00:00:00 2001 From: justbur Date: Tue, 21 Jul 2015 08:09:41 -0400 Subject: [PATCH] Show page count with prefix --- which-key.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/which-key.el b/which-key.el index 05552b3315e..5d3ac667ea7 100644 --- a/which-key.el +++ b/which-key.el @@ -845,6 +845,7 @@ element in each list element of KEYS." (page-width 0) (n-pages 0) page-cols pages keys/page page-widths) (if (> (car (car cols-w-widths)) avl-width) + ;; give up if first column doesn't fit (list :pages nil :page-height 0 :page-widths '(0) :keys/page '(0) :n-pages 0 :tot-keys 0) (dolist (col cols-w-widths) @@ -919,15 +920,22 @@ PREFIX-KEYS holds the description of the prefix keys." (n-shown (nth i (plist-get which-key--pages-plist :keys/page))) (n-tot (plist-get which-key--pages-plist :tot-keys)) (prefix-w-face (which-key--propertize-key prefix-keys)) - (prefix-width (string-width prefix-w-face)) - spaces) + (status-left (propertize (format "%s/%s" (1+ i) n-pages) + 'face 'font-lock-comment-face)) + (status-top (propertize (format "[%s/%s]" (1+ i) n-pages) + 'face 'font-lock-comment-face)) + (first-col-width (+ 2 (max (string-width prefix-w-face) + (string-width status-left)))) + (prefix-left (s-pad-right first-col-width " " prefix-w-face)) + (status-left (s-pad-right first-col-width " " status-left)) + new-end lines) (cond ((eq which-key-show-prefix 'left) - (setq spaces (s-repeat prefix-width " ") - page (concat - prefix-w-face " " - (s-replace "\n" (concat "\n " spaces) page)))) + (setq lines (split-string page "\n") + first (concat prefix-left (car lines) "\n" status-left) + new-end (concat "\n" (s-repeat first-col-width " ")) + page (concat first (mapconcat #'identity (cdr lines) new-end)))) ((eq which-key-show-prefix 'top) - (setq page (concat prefix-w-face "-\n" page)))) + (setq page (concat prefix-w-face "- " status-top "\n" page)))) (which-key--lighter-status n-shown n-tot) (if (eq which-key-popup-type 'minibuffer) (let (message-log-max) (message "%s" page)) -- 2.30.2